package leetcode.p1668;

/**
 * @author: trtan
 * @create: 2021-04-09 17:26
 * @description:
 **/
public class MaximumRepeatingSubstring {
    public static void main(String[] args) {

    }

    public int maxRepeating(String sequence, String word) {
        char[] a = sequence.toCharArray();
        char[] b = word.toCharArray();
        int result = 0;
        for (int i = 0; i < a.length - b.length + 1; i++) {
            int x = i;
            int k = 0;
            int count = 0;
            while (x < a.length) {
                if (a[x++] != b[k++]) {
                    break;
                }
                if (k == b.length) {
                    k = 0;
                    count++;
                }
            }
            result = Math.max(result, count);
        }
        return result;
    }
}
